package com.gds.wiki.cloud.admin.server.modular.sys.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gds.wiki.cloud.admin.client.sys.dto.AdminUserDto;
import com.gds.wiki.cloud.admin.client.sys.model.Role;
import com.gds.wiki.cloud.admin.client.sys.model.query.RoleQuery;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/*
* 
* gen by beetlsql mapper 2018-04-23
*/
public interface RoleMapper extends BaseMapper<Role> {
    @Select("select name from sys_role a join sys_user_role b on a.id=b.role_id where b.user_id=#{uid}")
    List<Map> getRoleByUid(@Param("uid") Long uid);

    @Delete("delete from sys_role_resource where role_id=#{rid}")
    int DelRoleResourceBy(Long rid);

    @Select("select a.id,a.name from sys_role a left join sys_dept b on a.dept_id =b.id where b.pids like CONCAT('%[',#{deptId},']%') or a.dept_id=#{deptId}" +
            " and a.status <>-1")
    List<Map> getRoleByDeptId(Long deptId);

    Page<AdminUserDto> getRoleWithDept(Page<AdminUserDto> page, @Param("roleQuery") RoleQuery roleQuery);

}
